package logic

import (
	"context"
	"doc-manage/model"

	"doc-manage/docrpc/docrpc"
	"doc-manage/docrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DocShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDocShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocShowLogic {
	return &DocShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DocShowLogic) DocShow(in *docrpc.DocShowRequest) (*docrpc.DocShowResponse, error) {
	// todo: add your logic here and delete this line
	var data model.Doc
	err := data.DocShow(model.DB, int(in.DocId))
	if err != nil {
		return nil, err
	}
	return &docrpc.DocShowResponse{
		DocName:    data.DocName,
		Address:    data.Address,
		DocContent: data.DocContent,
	}, nil
}
